<?php

namespace Managers;

class Warcraft extends \Lib\Model\DoctrineManager{
    
    public function getData($userId){
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('w')
                ->from('Entities\WarcraftUser', 'w')
                ->where('w.userId = :userId')
                ->setParameter('userId', $userId);
        $result = $qb->getQuery()->getSingleResult();
        return $result;
    }
    
    public function getMaps($userId,$maps){
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('m')
                ->from('Entities\WarcraftMap', 'm')
                ->where('m.mapId IN ('.\implode(',', $maps).')');
        $result = $qb->getQuery()->getResult();
        return $result;
    }
    
    public function getAllMaps(){
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('m')
                ->from('Entities\WarcraftMap', 'm');
        $result = $qb->getQuery()->getResult();
        return $result;
    }
    
      public function getSelectedMaps($mapsArray){
        $em = $this->getEntityManager();
        $qb = $em->createQueryBuilder()
                ->select('m')
                ->from('Entities\WarcraftMap', 'm')
                ->where('m.mapId IN ('.\implode(',', $mapsArray).')');
        $result = $qb->getQuery()->getResult();
        return $result;
    }
    
    public function saveMaps($userId, $maps) {
      
    }
    
    
}